variables:
  - &alpine_image 'alpine:3.19'
  - &git_image 'woodpeckerci/plugin-git:latest'
  - &mkdocs_image 'woodpeckerci/plugin-mkdocs:latest'
  - path: &docs_path
      include: ['doc/**', 'mkdocs.yml']

when:
  - event: push
    path: *docs_path
    branch: [ v2 ]
  - event: [ tag, release, manual ]

clone:
  - name: git
    image: *git_image
    settings:
      partial: false
      depth: 0

steps:
  generate-docs:
    image: *mkdocs_image
    settings:
      verbose: true
      pip_install_file: doc/requirements.txt

  deploy-docs-cloudflare:
    image: *alpine_image
    environment:
      CLOUDFLARE_ACCOUNT_ID:
        from_secret: CLOUDFLARE_ACCOUNT_ID
      CLOUDFLARE_API_TOKEN:
        from_secret: CLOUDFLARE_API_TOKEN
    commands:
      - apk add npm --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/
      - npx wrangler pages deploy site --project-name=pixivfe-docs
    depends_on:
      - generate-docs
